package Chapter5;

class YieldThread implements Runnable{
	
	public void run() {
		for(int i=0;i<5;i++) {
			System.out.println(Thread.currentThread().getName()+"---"+i);
			if(i==3) {
				System.out.println("线程让步");
				Thread.yield();
			}
		}
	}
}

public class Example09 {
	public static void main(String[] args) {
		Thread t1=new Thread(new YieldThread(),"thread A");
		Thread t2=new Thread(new YieldThread(),"thread B");
		t1.start();
		t2.start();
	}
	
}
